<script setup>
import {userInfo} from "@/stores/userStore.js";
import {ref} from "vue";
import {useI18n} from 'vue-i18n'

const {locale} = useI18n();
const skinColor = ref(true);

const skinColorChange = (param) => {
  document.documentElement.className = !param ? 'dark' : '';
}

const changeLanguage = (param) => {
  userInfo().language = param;
  locale.value = userInfo().language;
}
</script>

<template>
  <div class="user-info-space">
    <el-dropdown
        @command="changeLanguage"
    >
      <el-text>{{$t('language')}}</el-text>
      <template #dropdown>
        <el-dropdown-menu>
          <el-dropdown-item command="zh">
            中文
          </el-dropdown-item>
          <el-dropdown-item command="en">
            English
          </el-dropdown-item>
        </el-dropdown-menu>
      </template>
    </el-dropdown>
    <div>
      <el-switch
          @change="skinColorChange"
          v-model="skinColor"
          :active-action-icon="'Sunny'"
          :inactive-action-icon="'Moon'"
      />
    </div>
    <div>
      <el-avatar
          :src="userInfo().avatarUrl"
      />
    </div>

  </div>
</template>

<style scoped lang="scss">
.user-info-space {
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;

  & > div {
    margin: 0 8px 0 8px;
  }
}
</style>